#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> selectionSort(vector<int>& v)
{
    for(int i=0;i<v.size();i++)
    {
        int minIndex=i;
        for(int j=i+1;j<v.size();j++)
        {
            if(v[minIndex]>v[j])
                minIndex=j;
        }
        swap(v[i],v[minIndex]);
        cout<<"the "<<i+1<<"th time"<<endl;
        for(int i=0;i<v.size();i++)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
    }
    return v;
}

int main()
{
    cout<<"Enter the numbers:"<<endl;
    vector<int> v;
    int n;
    while(n!=-1)
    {
        cin>>n;
        v.push_back(n);
    }
    v.pop_back();
    v=selectionSort(v);
    cout<<"the sorted array is:"<<endl;
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    return 0;
}
